package com.voygern.task1.dao;

import java.io.IOException;
import java.io.Reader;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.stereotype.Repository;

import com.voygern.task1.dao.mapper.UserDaoMapper;
@Repository
public class DBAccess {
		public SqlSession getSession() throws IOException
		{
			Reader reader = Resources.getResourceAsReader("MybatisConfig.xml");
			SqlSessionFactory factory =new SqlSessionFactoryBuilder().build(reader);
			SqlSession session = factory.openSession(true);
			session.getConfiguration().addMapper(UserDaoMapper.class);
			return session;
		}
}
